/**   
 * @Title: HelpAndAboutActivity.java 
 * @Package com.fone.player.activity.personal
 * Copyright: Copyright (c) 2014
 * Company: 100tv
 * @Description:  帮助和关于共用的activity,具体内容加载采用的静态页面
 * @author JasonZue  jczhu@100tv.com   
 * @date 2014-4-28 下午1:40:04 
 * @version V1.0   
 */

package com.fone.player.activity.personal;

import java.lang.reflect.Field;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;

import com.fone.player.R;
import com.fone.player.activity.BaseActivity;

/**
 * 帮助和关于共用的activity 具体内容加载采用的静态页面
 * 
 * @author JasonZue
 * @since 2014-4-28
 */

public class HelpAndAboutActivity extends BaseActivity {

	private WebView mWv;
	private TextView mTitleTv;
	private Button mLeftBt, mRightBt;
	private int mType;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.personal_help_about_view);
		Intent intent = this.getIntent();
		mType = intent.getIntExtra("type", 0);

		initView();
	}

	/**
	 * 初始化界面
	 * 
	 * @return void
	 * @throws
	 */

	private void initView() {
		mLeftBt = (Button) findViewById(R.id.common_title_left_bt);
		mRightBt = (Button) findViewById(R.id.common_title_right_bt);
		mTitleTv = (TextView) findViewById(R.id.common_title_text_tv);

		mLeftBt.setText("设置");
		mRightBt.setVisibility(View.GONE);
		mTitleTv.setVisibility(View.GONE);
		mWv = (WebView) findViewById(R.id.personal_wv);
		switch (mType) {
		case SettingActivity.TYPE_ABOUT:
			mLeftBt.setText("关于和帮助");
			mWv.loadUrl("file:///android_asset/about.html");
			break;
		case SettingActivity.TYPE_LAW:
			mLeftBt.setText("法律声明");
			// TODO 修改法律声明的本地网页,目前用原帮助代替
			mWv.loadUrl("file:///android_asset/help.html");
			break;

		default:
			mWv.loadUrl("file:///android_asset/help.html");
			break;
		}
		mWv.setOnLongClickListener(new OnLongClickListener() {

			@Override
			public boolean onLongClick(View v) {
				return true;
			}
		});
		mWv.setOnFocusChangeListener(new View.OnFocusChangeListener() {
			@Override
			public void onFocusChange(View v, boolean hasFocus) {
				if (hasFocus) {
					try {
						//fix 2737 禁止网页上的缩放
						Field defaultScale = WebView.class
								.getDeclaredField("mDefaultScale");
						defaultScale.setAccessible(true);
						defaultScale.setFloat(mWv, 1.0f);
					} catch (SecurityException e) {
						e.printStackTrace();
					} catch (IllegalArgumentException e) {
						e.printStackTrace();
					} catch (IllegalAccessException e) {
						e.printStackTrace();
					} catch (NoSuchFieldException e) {
						e.printStackTrace();
					}
				}
			}
		});

		mLeftBt.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();

			}
		});
	}

}
